<!DOCTYPE html>
<html xmlns:th="http://www.springframework.org/schema/mvc">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	   <form id="memu_update_form">
	   <div style="width: 200px;margin:10px auto">
            <input type="hidden" name="id">
            <div style="margin-bottom:20px;">
                <label for="name">菜单名称</label>
		       <input id="memu_update_form_name" class="easyui-textbox" type="text" name="name" data-options="required:true" style="width:200px"/>
            </div>
             <div style="margin-bottom:20px;">
              <label for="status">状态</label>
			  <input id="memu_update_form_status" class="easyui-textbox" type="text" name="status" data-options="required:true" style="width:200px"/>
            </div>
            <div style="margin-bottom:20px;">
            	<label for="sortOrder">排序</label>
			  	<input id="memu_update_form_sortOrder" class="easyui-textbox" type="text" name="sortOrder"  style="width:200px"/>
            </div>
            <div style="margin-bottom:20px;">
                <label for="urlPath">菜单路径</label>
			    <input id="memu_update_form_urlPath" class="easyui-textbox" type="text" name="urlPath" data-options="required:true" style="width:200px"/>
            </div>
            <div style="margin-bottom:30px;">
	            <div>
			       <label for="email">是否有父菜单:</label>
			       是<input class="easyui-validatebox" type="radio" name="isParent" value="1"/>
			       否<input class="easyui-validatebox" type="radio" name="isParent" value="0" />
			   </div>
		   </div>
	            <div id="menu_show_wa">
			       <label for="parentId">父菜单</label>
					<select id="memu_update_form_parentId"  name="parentId"  style="width:200px;"></select>
				</div>
           </div>
        </form>
<script th:inline="none" type="text/javascript" >
	var menuRows = $('#menu_manage').datagrid('getSelections');
	var allRows = $('#menu_manage').datagrid('getData');

	//初始化父菜单，必须用这个变量，不然报错
	var memuUpdateFormParentId =$("#memu_update_form_parentId").combotree({
		checkbox:true,
		//multiple: true 复选框
	});

	memuUpdateFormParentId.combotree('loadData',memuUpdateFormData());
	//设置父亲节点值
	checkNone();
	function checkNone(){
		if(menuRows[0].isParent){
			var parentId=menuRows[0].parentId;
			var rows=allRows.rows;
			for(var i=0;i<rows.length;i++){
				if(parentId==rows[i].id){
					memuUpdateFormParentId.combotree('setValue',{
						id:parentId,
						text:rows[i].text
					});
				}
			}
		}
	}


	$(function(){
		//初始化父节点是否显示
		if(menuRows[0].isParent){
			$("#memu_update_form input[name=isParent]").eq(0).attr("checked",true);
		}else{
			$("#memu_update_form input[name=isParent]").eq(1).attr("checked",true);
			$("#menu_show_wa").hide();
		}
		
		
		$("#memu_update_form input[name=isParent]").click(function(){
			if(this.value==1){
				console.log($("#menu_show_wa"));
				$("#menu_show_wa").show();
				$("#memu_update_form_parentId").combotree('resetValidation');
				$("#memu_update_form_parentId").combotree('enableValidation');
			}else{
				$("#menu_show_wa").hide();
				$("#memu_update_form_parentId").combotree('disableValidation');
			}
		})
	})
  </script>
</body>
</html>